/* scrn.h */

/* Code for screen handling.
   In the actual plot routines the offset value is the offset between rows
   (single, not doubled up)
   A BOOL return value indicates success/failure */

#ifndef __scrn_h
#define __scrn_h

#include "DeskLib:Core.h"

#include "graphics.h"

/* Types of display */
typedef enum {
  scrn_standard,   /* 320*256 */
  scrn_single_vga, /* 320*480, each alternate line is skipped */
  scrn_double_vga  /* 320*480, each alternate line is a copy of one above
  		    (hereafter called 'line-doubling') */
} scrn_type;

/* Set screen mode */
BOOL scrn_set_mode(int mode);

/* Set up tables etc needed by other functions; */
BOOL scrn_setup(scrn_type type);

/* typedef for functions below */
typedef void (*scrn_plotter)(graphic *sprite,int x,int y,int offset);
/* and for clock plotter */
typedef void (*scrn_clocker)(int rowsize);

/* Plot a sprite at given coordinates (assuming screen size of 320x240;
   origin at *top* left)
   offset is redundant here */
void scrn_plot(graphic *sprite,int x,int y,int offset);

/* As above but faster, coords must give word-aligned address */
void scrn_fast_plot(graphic *sprite,int x,int y,int offset);

/* As above with line doubling for enhanced VGA
   offset is offset between 2 single rows */
extern void scrn_plot_vga(graphic *sprite,int x,int y,int offset);
extern void scrn_fast_plot_vga(graphic *sprite,int x,int y,int offset);

/* Pointers to functions, so we have choice of line-doubling or not */
extern scrn_plotter scrn_slow_plotter,scrn_fast_plotter;
extern scrn_clocker scrn_clock_plotter;

/* Cancel screen banking */
void scrn_cancel_banking(void);

/* Start screen banking */
void scrn_start_banking(void);

/* Swap screen banks at next vsync */
void scrn_swap_banks(void);

/* Wait for next vsync */
void scrn_wait(void);

/* Turn off cursor */
void scrn_cursor_off(void);

/* Cursor must be restored */
void scrn_cursor_on(void);

/* Save/restore desktop mode */
void scrn_save_desktop_mode(void);
void scrn_restore_desktop_mode(void);

/* Offset between 2 single rows in line-doubling VGA */
extern int scrn_offset;

/* There are 2 variables for each of the below values because of the ARM's
   unique addressing system
 */

/* Work bank base address for m/code */
extern void *scrn_address;
extern void *scrn_address2;

/* Offset between 2 plotted rows for m/code */
extern int scrn_rowsize;
extern int scrn_rowsize2;

/* M/code's pointer to screen row table */
extern int *scrn_table_ptr;
extern int *scrn_table_ptr2;

/* Screen bank being worked on */
extern int scrn_work_bank;

/* Screen base addresses for each bank */
extern void *scrn_bank_base[2];

#endif
